/**
 *  pickers.vala
 *
 *  Copyright (c) 2007 Marcelo Lira dos Santos <setanta@gmail.com>
 *                2007 INdT (Instituto Nokia de Technologia)
 *
 *  Author: Marcelo Lira dos Santos <setanta@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA
 */

using GLib;
using Gtk;

public class PickersDemo : GLib.Object
{

    public Window do_pickers ()
    {
        Window window = new Window(WindowType.TOPLEVEL);
        window.title = "Pickers";
        window.border_width = 10;
        window.destroy += Gtk.main_quit;

        Table table = new Table(4, 2, false);
        table.set_col_spacing(0, 10);
        table.set_row_spacings(3);
        table.border_width = 10;
        window.add(table);

        Label label = new Label("Color:");
        label.set_alignment((float) 0.0, (float) 0.5);
        ColorButton picker1 = new ColorButton();
        table.attach_defaults(label, 0, 1, 0, 1);
        table.attach_defaults(picker1, 1, 2, 0, 1);

        label = new Label("Font:");
        label.set_alignment((float) 0.0, (float) 0.5);
        FontButton picker2 = new FontButton();
        table.attach_defaults(label, 0, 1, 1, 2);
        table.attach_defaults(picker2, 1, 2, 1, 2);

        label = new Label("File:");
        label.set_alignment((float) 0.0, (float) 0.5);
        FileChooserButton picker3 = new FileChooserButton("Pick a File", FileChooserAction.OPEN);
        table.attach_defaults(label, 0, 1, 2, 3);
        table.attach_defaults(picker3, 1, 2, 2, 3);

        label = new Label("Folder:");
        label.set_alignment((float) 0.0, (float) 0.5);
        FileChooserButton picker4 = new FileChooserButton("Pick a Folder", FileChooserAction.SELECT_FOLDER);
        table.attach_defaults(label, 0, 1, 3, 4);
        table.attach_defaults(picker4, 1, 2, 3, 4);

        return window;
    }

    static int main (string[] args) {
        Gtk.init(out args);

        PickersDemo pd = new PickersDemo();

        var win = pd.do_pickers();
        try {
            win.set_default_icon_from_file("v-icon.png");
        } catch (GLib.Error error) {
            critical(error.message);
        }
        win.show_all();

        Gtk.main();

        return 0;
    }
}
